import { http } from "@/plugin/http";

// 埋点
export const onBuriedPoint = async (params: API.User.BuriedPointParams) => {
  try {
    await http.post<API.Home.BannerResult>(
      "/user/buried-point",
      JSON.stringify(params),
      null,
      {
        "Content-Type": "application/x-www-form-urlencoded",
      }
    );
    return true;
  } catch (error) {
    return true;
  }
};

// 退款
export const withdraw = async (params: API.User.WithdrawParams) => {
  try {
    await http.post("/payment/withdraw/create", params);
    return true;
  } catch (error) {
    return false;
  }
};

// 退款
export const withdrawChannels = async () => {
  try {
    return await http.post<API.User.WithdrawChannelListResp>("/payment/withdraw/channel-list");
  } catch (error) {
    return null;
  }
};

// 充值-Cash
export const cash = async (params: API.User.CashParams) => {
  try {
    return await http.post<API.User.CashResponse>(
      "/payment/deposit/create",
      params
    );
  } catch (error) {
    return null;
  }
};

// 充值-比特币
export const crypto = async (params: API.User.CryptoParams) => {
  try {
    return await http.post<API.User.CashResponse>(
      "/user/recharge/crypto",
      params
    );
  } catch (error) {
    return null;
  }
};

// 充值所需信息
export const getDepositInfo = async () => {
  try {
    return await http.post<API.User.RechargeInfoResponse>(
      "/payment/deposit/channel-list"
    );
  } catch (error) {
    return null;
  }
};
